package festival.player;

import java.awt.GridLayout;

import javax.swing.JPanel;

public class PlayerPanel extends JPanel {
    
    private int mNumPlayers;
    private int mSelectedPlayer;
    private PlayerView[] mPlayerViews;
    
    public PlayerPanel(Player[] players) {
        super();
        mNumPlayers = players.length;
        setLayout(new GridLayout(4, 1));
        mPlayerViews = new PlayerView[mNumPlayers];
        int i = 0;
        for(Player p : players) {
            PlayerView pv = new PlayerView(p);
            add(pv);
            mPlayerViews[i] = pv;
            i++;
        }
    }
    
    public void setSelectedPlayer(int playerIndex) {
        for(PlayerView pv : mPlayerViews) {
            pv.setSelected(false);
        }
        mPlayerViews[playerIndex].setSelected(true);
    }
}
